package com.atguigu.statservice.controller;


import com.atguigu.commonutils.R;
import com.atguigu.statservice.service.StatisticsDailyService;
import org.apache.tomcat.jni.Mmap;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * <p>
 * 网站统计日数据 前端控制器
 * </p>
 *
 * @author thomasyang
 * @since 2023-12-25
 */
@CrossOrigin
@RestController
@RequestMapping("/statservice/stat")
public class StatisticsDailyController {


    @Autowired
    private StatisticsDailyService statisticsDailyService;




    //统计某一天注册人数,生成统计数据
    @PostMapping(value = "countregister/{day}")
    public R registerCount(@PathVariable String day){

        statisticsDailyService.registerCount(day);
        return R.ok();

    }

    //图表显示，返回两部分数据，日期json数组，数量json数组
    @GetMapping("showData/{type}/{begin}/{end}")
    public R showData(@PathVariable String type, @PathVariable String begin,
                      @PathVariable String end){

        Map<String, Object> map =   statisticsDailyService.showData(type, begin, end);

        return R.ok().data(map);

    }



}

